package com.hnkywl.sts.action.zjgl;

import com.hnkywl.sts.entity.sys.Gncz;
import com.hnkywl.sts.entity.zjgl.Hthk;
import com.hnkywl.sts.service.sys.GnczService;
import com.hnkywl.sts.service.zjgl.HthkService;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 说明：
 * 包:        com.hnkywl.sts.action.sfgl
 * 类描述:    合同货款Action类
 * 修改备注: [说明本次修改内容]
 * 版本:        [v1.0]
 */
@Namespace("/zjgl/hthk")
public class HthkAction extends SimpleActionSupport {

    private int page;
    //分页组件 页面大小
    private int rows = 10;
    //功能操作
    private List<Gncz> gnczList;
    private GnczService gnczService;
    private HthkService hthkService;
    private Long gsId;
    private String khMc;
    private String hth;
    private Hthk hthk;
    private Long hthkid;

    @Action("hthk")
    public String hthk() {
        gnczList = gnczService.findGnczByJsAndUrl(request.getServletPath());
        return SUCCESS;
    }

    // 合同货款分页显示
    @Action("hthkList")
    public void bzjList() {
        this.renderJson(this.hthkService.findAllHthk(gsId, khMc, hth, page, rows));
    }

    // 弹出新增页面
    @Action("hthk_content")
    public String hthk_content() {
        hthk = new Hthk();
        return SUCCESS;
    }

    /**
     * 增加合同货款
     */
    @Action("add_hthk")
    public void add_hthk() {
        try {
            this.hthkService.saveHthk(hthk);
            renderText("{\"statusCode\":\"200\", \"message\":\"添加合同货款采购！\", \"operationType\":\"add\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }

    /**
     * 解锁
     */
    @Action("js_hthk")
    public void js_hthk() {
        try {
            this.hthkService.jsHthk(hthkid);
            renderText("{\"statusCode\":\"200\", \"message\":\"解锁合同货款成功！\", \"operationType\":\"add\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }
    /**
     * 锁定
     */
    @Action("sd_hthk")
    public void sd_hthk() {
        try {
            this.hthkService.sdHthk(hthkid);
            renderText("{\"statusCode\":\"200\", \"message\":\"锁定合同货款成功！\", \"operationType\":\"add\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }
    @Action("delete_hthk")
    public void deletehthk() {
        try {
            this.hthkService.deletehthk(hthkid);
            renderText("{\"statusCode\":\"200\", \"message\":\"删除成功！\", \"operationType\":\"delete\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public List<Gncz> getGnczList() {
        return gnczList;
    }

    public void setGnczList(List<Gncz> gnczList) {
        this.gnczList = gnczList;
    }

    public Long getGsId() {
        return gsId;
    }

    public void setGsId(Long gsId) {
        this.gsId = gsId;
    }

    public String getKhMc() {
        return khMc;
    }

    public void setKhMc(String khMc) {
        this.khMc = khMc;
    }

    public String getHth() {
        return hth;
    }

    public void setHth(String hth) {
        this.hth = hth;
    }

    public Hthk getHthk() {
        return hthk;
    }

    public void setHthk(Hthk hthk) {
        this.hthk = hthk;
    }

    public Long getHthkid() {
        return hthkid;
    }

    public void setHthkid(Long hthkid) {
        this.hthkid = hthkid;
    }

    @Autowired
    public void setGnczService(GnczService gnczService) {
        this.gnczService = gnczService;
    }

    @Autowired
    public void setHthkService(HthkService hthkService) {
        this.hthkService = hthkService;
    }
}
